//
//  GQSiteController.m
//  GuQu
//
//  Created by HELIUM STAR on 15/5/6.
//  Copyright (c) 2015年 HELIUM STAR. All rights reserved.
//

#import "GQSiteController.h"

@implementation GQSiteController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.tableView.frame = CGRectMake(0, kNavigatationBarHeight + 30, kScreenWidth, kScreenHeight);
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageWithOriginalName:@"distribute_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backToPre)];
    self.navigationItem.title = @"所在地";
    
    
}

- (void)backToPre
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (instancetype)initWithStyle:(UITableViewStyle)style
{
    if (self == [super initWithStyle:UITableViewStyleGrouped]) {
        
    }
    return self;
}

- (NSArray *)cities
{
    if (_cities == nil) {
        _cities = [NSArray arrayWithObjects:@"北京", @"广州", @"上海", @"天津", @"金华", @"武汉", @"南京", @"无锡", nil];
    }
    return _cities;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return @"定位";
    }else{
        return @"全部";
    }
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 30;
}


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    }else if(section == 1){
        return self.cities.count;
    }
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *flag = @"flag";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:flag];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:flag];
    }
    if (indexPath.row == 0) {
        cell.textLabel.text = @"杭州";
        return cell;
    }
    cell.textLabel.text = self.cities[indexPath.row];
    return cell;
}

@end
